package com.ysd.dao.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.ysd.entity.XiangQing;
import com.ysd.util.DBManager;

public class XiangQingDaoImpl {
	/**
	 * 
	 * @param cId 产品分类Id
	 * @return
	 */
	public List<XiangQing> getXiangQingsList(int cId){//什么是有看参数呢?一般看sql语句有条件没有
		List<XiangQing> xiangqingList = new ArrayList<XiangQing>();
		
		Connection conn = DBManager.getConnection();
		Statement st = null;
		ResultSet rs = null;
		
		try {
			st = conn.createStatement();
			rs = st.executeQuery("select * from zxxiangqing where zXXiangQingID="+cId);
			while (rs.next()) {
				int pId = rs.getInt("zXXiangQingID");
				String pName = rs.getString("zXBiaoTi");
				String imgs = rs.getString("zXNeiRong");
				String zxnr=rs.getString("zXBTNeiRong");
				XiangQing xiangqing = new XiangQing(pId, pName, imgs, zxnr, pId);
				xiangqingList.add(xiangqing);
			}return xiangqingList;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}finally {
			DBManager.closeAll(conn, st, rs);
		}
	}
}
